package com.cl.mybatis.learn.day13;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class Mybatis001 {
    public static void main(String[] args) throws Exception {
        
        String resource = "day13/mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        
        SqlSession session = sqlSessionFactory.openSession();

        try {
            UserMapper mapper = session.getMapper(UserMapper.class);
            User test3 = mapper.selectById(7);
            System.out.println("第1次：" + test3);
            
        } finally {
            session.close();
        }
        
    }

}
